// 处理参数拼接在url上面的操作
function handlerGetUrlParams(baseUrl, params) {
  const keys = Object.keys(params)
  if (keys.length === 0) return baseUrl
  const urls = keys.reduce((pre, cur) => {
    const v = params[cur]
    if (v !== undefined) {
      pre.push(`${cur}=${params[cur]}`)
    }
    return pre
  }, [])
  return urls.length > 0 ? `${baseUrl}?${urls.join('&')}` : baseUrl
}

module.exports = {
  handlerGetUrlParams
}
